﻿
@{
    ViewBag.Title = "Menu";
}

<link href="~/css/common.css" rel="stylesheet" />
<style type="text/css">
    .my-nav {
        border-bottom: solid 1px #ccc;
    }

        .my-nav .nav-title {
            font-size: 1rem;
            line-height: 2rem;
            color: #444;
        }

        .my-nav .nav-content li {
            margin-bottom: 0.5rem;
            margin-right: 0.5rem;
        }

            .my-nav .nav-content li a {
                color: #444;
            }

    .aui-content-padded {
        margin: 4.75rem 0.75rem 3.75rem 0.75rem;
    }

    .swiper-xlbtn {
        position: absolute;
        margin-top: -1rem;
        z-index: 999999;
        width: 2rem;
        height: 2rem;
        background-color: #eee;
        right: 0;
        filter: alpha(opacity=50);
        -moz-opacity: 0.5;
        -khtml-opacity: 0.5;
        opacity: 0.9;
    }
</style>

<header class="aui-bar aui-bar-nav" id="aui-header">
    <div class="aui-title">首页</div>
    <a href="~/Index/Search" class="aui-pull-right aui-btn aui-btn-outlined"> <span class="aui-iconfont aui-icon-search"></span> </a>
</header>

<!--全部菜单Start-->
<div class="swiper-xlbtn" style="z-index:999999;background:none;">
    <img src="~/image/xiala.png" style="margin: 0.7rem 0 0 0.5rem;">
</div>
<div id="allMenu" class="aui-content-padded">

</div>
<!--全部菜单End-->

<!--加载动画Start-->
<div id="loading">
    <div class="loading">
        <img src="~/image/loading.gif" />
    </div>
</div>
<!--加载动画End-->

<script type="text/javascript">

    $(function () {
        //返回首页
        $(".swiper-xlbtn").click(function () {
            window.location.href = '@Url.Action("Index")';
        });

        //加载全部菜单
        $.ajax({
            url: "http://shtdj.shanhaitian.gov.cn/AppInterface/api/Frame/GetMenu",
            type: "POST",
            contentType: "application/json",
            data: JSON.stringify({ ID: 'HomePageMore', IsChild: 'true' }),
            dataType: "json",
            success: function (data, status) {
                var dd = eval(data.result);
                var str = "";
                for (var i = 0; i < dd.length; i++) {
                    //循环出一级菜单
                    if (dd[i].ParentID == "HomePageMore") {
                        str += '<section class="aui-content aui-padded-t-5 aui-padded-b-10 my-nav">';
                        str += '<div class="aui-title nav-title">' + dd[i].Name + '</div>';
                        str += '<ul class="aui-list aui-list-in nav-content">';

                        for (var j = 0; j < dd.length; j++) {
                            if (dd[j].ParentID == dd[i].ID) {
                                str += '<li class="aui-btn aui-btn-outlined"><a href="' + dd[j].NavigateUrl + '">' + dd[j].Name + '</a></li>';
                            }
                        }
                        str += '</ul>';
                        str += '</section>';
                    }
                }

                $("#allMenu").html(str);
                //隐藏加载动画
                $("#loading").hide();
            },
            error: function (xhr, textStatus) {
                console.log('错误')
                console.log(xhr)
                console.log(textStatus)
            }
        });

    });

</script>
